package com.csist.service.po.basicInfoModule.impl;


import com.csist.mapper.po.basicInfoModule.EducationMethodMapper;
import com.csist.pojo.po.basicInfoModule.EducationBackground;
import com.csist.pojo.po.basicInfoModule.EducationMethod;
import com.csist.service.po.basicInfoModule.EducationMethodService;
import com.csist.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName EducationMethodServiceImpl
 * @Description 【自行描述】
 * @Author cn
 * @Date 2024/6/27 12:32
 * @Version 1.0
 */
public class EducationMethodServiceImpl implements EducationMethodService {
    private SqlSession sqlSession;
    private EducationMethodMapper educationMethodMapper;

    public EducationMethodServiceImpl() {
        sqlSession = SqlSessionUtil.openSession();
        educationMethodMapper = sqlSession.getMapper(EducationMethodMapper.class);
    }

    @Override
    public List<EducationMethod> findAll() {
        List<EducationMethod> list = educationMethodMapper.findAll();
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public EducationMethod getEducationMethodById(int id) {
        EducationMethod educationMethodById = educationMethodMapper.getEducationMethodById(id);
        if (educationMethodById != null) {
            return educationMethodById;
        }
        return null;
    }

    @Override
    public List<EducationMethod> findEducationMethodFuzzy(EducationMethod educationMethod) {
        List<EducationMethod> list = educationMethodMapper.findEducationMethodFuzzy(educationMethod);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public List<EducationMethod> findEducationMethod(EducationMethod educationMethod) {
        List<EducationMethod> list = educationMethodMapper.findEducationMethod(educationMethod);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public int addEducationMethod(EducationMethod educationMethod) {
        int i = educationMethodMapper.addEducationMethod(educationMethod);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateEducationMethod(EducationMethod educationMethod) {
        int i = educationMethodMapper.updateEducationMethod(educationMethod);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateEducationMethodByState(int ebId) {
        int i = educationMethodMapper.updateEducationMethodByState(ebId);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int deleteEducationMethod(int emId) {
        return 0;
    }
}
